<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 原始代码
function processValue(value) {
  if (value === null) {
    return 'Null value';
  } else if (value === undefined) {
    return 'Undefined value';
  } else if (typeof value === 'number') {
    return value * 2;
  } else if (typeof value === 'string') {
    return value.toUpperCase();
  } else if (Array.isArray(value)) {
    return value.join(',');
  }
}

// 优化后
const processors = [
  { check: v => v === null, process: () => 'Null value' },
  { check: v => v === undefined, process: () => 'Undefined value' },
  { check: v => typeof v === 'number', process: v => v * 2 },
  { check: v => typeof v === 'string', process: v => v.toUpperCase() },
  { check: Array.isArray, process: v => v.join(',') }
];

function processValue(value) {
  const processor = processors.find(p => p.check(value));
  return processor ? processor.process(value) : 'Unknown type';
}
</script>
</html>